﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ManWebRole.Models
{
    public class HistoryModel
    {
        private SkySRMDBDataDataContext db = new SkySRMDBDataDataContext();

        public void AddHistory(History history)
        {
            db.Histories.InsertOnSubmit(history);
            db.SubmitChanges();
        }

        public History GetHistoryById(int id)
        {
            return db.Histories.SingleOrDefault(h => h.Id == id);
        }

        public IEnumerable<History> GetHistoriesBySectionId(int sectionId)
        {
            return db.Histories.TakeWhile(h => h.SectionId == sectionId);
        }

    }
}